


float4x4 g_projMatrix : PROJ;
float4x4 g_viewMatrix : VIEW;
float4x4 g_worldMatrix : WORLD;

/*
float4 g_lightAmbient : LIGHTAMBIENT;
float4 g_lightDiffuse : LIGHTDIFFUSE;
float4 g_lightSpecular : LIGHTSPECULAR;
float3 g_lightPosition : LIGHTPOSITION;

float g_matPower : MATERIALPOWER;
*/

texture g_texDiffuse : TEXTUREDIFFUSE;

float4 g_particelPosition : PARTICELPOSITION;
float4 g_particelTransRotAlpha: PARTICELTRANSROTALPHA;

sampler2D g_samDiffuse = 
sampler_state
{
	Texture = <g_texDiffuse>;
	MinFilter = Linear;
	MagFilter = Linear;
	MipFilter = Linear;
};


struct VS_OUTPUT
{
	float4 position		: POSITION;
	float2 txt			: TEXCOORD0;
};

struct PS_OUTPUT
{
	float4 color : COLOR0;
};

VS_OUTPUT MyVS(float4	pos		: POSITION,
			   float2   txt		: TEXCOORD0,
			   uniform float4x4 worldViewMatrix,
			   uniform float    sinA,
			   uniform float	cosA)
{
	VS_OUTPUT output;

	// perform rotations on the particel vertices
	float4 p = float4(pos.x * cosA - pos.y * sinA,
					  pos.x * sinA + pos.y * cosA,
					  pos.z, pos.w);

	// transform the particel position into the camera space
	float4 partPos = mul (g_particelPosition, worldViewMatrix);

	// add the position of the vertex to get the final position 
	// of the particel within camera space
	partPos = partPos + p;

	// by a multiplication with the proj matrix the final position
	// is calculated
	output.position = mul (partPos, g_projMatrix);

	//  there is no real lighting to perform
	output.txt = txt;

	return output;
}


PS_OUTPUT MyPS(VS_OUTPUT input)
{
	PS_OUTPUT output;

	output.color = tex2D (g_samDiffuse, input.txt);
	output.color.a *= g_particelTransRotAlpha.w ;
	return output;
}

technique TestTechnique
{
	pass P0
	{
		VertexShader = compile vs_2_0 MyVS(mul (g_worldMatrix, g_viewMatrix), sin(g_particelTransRotAlpha.z), cos(g_particelTransRotAlpha.z));
		PixelShader  = compile ps_2_0 MyPS();
	}
}